package ${packageName};
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import com.saluki.client.*;
import io.grpc.stub.StreamObserver;


public class ${serviceName}_service extends ${serviceName}Grpc.${serviceName}ImplBase {

    private static final Logger logger = LoggerFactory.getLogger(${serviceName}.class);

    @Autowired
    private ${serviceName} invoker;

<#list methods as method>
    public void ${method.methodName}(${method.requestType} request,StreamObserver<${method.responseType}> responseObserver) {
    try {
    ${method.responseType} result = invoker.${method.methodName}(request);
    responseObserver.onNext(result);
} catch (Exception e) {
    logger.error("saluki invoke error:", e);
    responseObserver.onError(new RuntimeException("saluki invoke error by " + Utils.getLocal(), e));
}
    responseObserver.onCompleted();

}
</#list>

    public void setInvoker(${serviceName} invoker) {
        this.invoker = invoker;
    }
}
